package com.ruoyi.order.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.order.domain.Order;
import com.ruoyi.order.service.IOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "基础管理-订单信息")
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    /**
     * 查询订单列表
     */
                @ApiOperation("订单管理 - 分页查询列表")
    @GetMapping("/list")
    public AjaxResult list() {
        List<Order> list = orderService.selectOrderList();
        return AjaxResult.success(list);
    }

    /**
     * 根据考生ID获取订单详情
     */
                @ApiOperation("订单管理 - 根据ID获取详细信息")
    @GetMapping("/info")
    public AjaxResult getInfo(@RequestParam String candidateId) {
        return AjaxResult.success(orderService.selectOrderById(candidateId));
    }

    /**
     * 新增订单
     */
                @ApiOperation("订单管理 - 新增数据")
    @PostMapping
    public AjaxResult add(@RequestBody Order order) {
        return AjaxResult.success(orderService.insertOrder(order));
    }

    /**
     * 修改订单
     */
                @ApiOperation("订单管理 - 修改数据")
    @PutMapping
    public AjaxResult edit(@RequestBody Order order) {
        return AjaxResult.success(orderService.updateOrder(order));
    }

    /**
     * 删除订单
     */
                @ApiOperation("订单管理 - 删除数据")
    @DeleteMapping
    public AjaxResult remove(@RequestParam String candidateId) {
        return AjaxResult.success(orderService.deleteOrderById(candidateId));
    }
}
